package com.webserver.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Author：毕龙
 * Date: 2022/9/18 13:39
 * 项目的主类 用于启动webserver
 * 该醒目的主要功能是实现Tomcat这个webServer的核心功能 了解HTTP协议以及浏览器与服务器
 * 之间的处理谢姐
 * 了解SpringMVC核心类的设计与实现
 */
public class BirdBootApplication {
    private ServerSocket serverSocket;

    public BirdBootApplication(){
       try {
           System.out.println("正在启动服务器......");
           serverSocket = new ServerSocket(8088);
           System.out.println("服务器启动完毕！");
       }catch (IOException e){
           e.printStackTrace();
       }
    }

    public void start(){
        try {
            System.out.println("等待客户端连接.....");
            Socket so = serverSocket.accept();
            System.out.println("一个客户端连接了!");
            //启动一个县城处理该客户端交互
            ClientHandler ch = new ClientHandler(so);
            Thread thread = new Thread(ch);
            thread.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        BirdBootApplication birdBootApplication = new BirdBootApplication();
        birdBootApplication.start();
    }
}
